package upms.svc.dubbo.main;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.rock.common.util.RockJsonUtil;
import com.rock.common.util.SpringContextUtil;
import com.rock.upms.api.upms.service.ILoginService;
import com.rock.upms.svc.upms.service.impl.LoginService;

public class UpmsDubboProviderMain {

	private static Logger log = LoggerFactory.getLogger(UpmsDubboProviderMain.class);

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			// String[] xmlstr = { "spring/applicationContext.xml",
			// "spring/applicationContext-jdbc.xml",
			// "spring/applicationContext-service.xml",
			// "spring/applicationContext-listener.xml",
			// "spring/applicationContext-dubbo.xml" };
			ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring/app*.xml");
			context.start();
			/*
			//初始化密码
			IUpmsPersonService upmsPersonSvc=(UpmsPersonService)SpringContextUtil.getBean(UpmsPersonService.class);
			UpmsPersonExample example=new UpmsPersonExample();
			example.createCriteria().andIdIsNotNull();
			java.util.List<UpmsPerson> list=upmsPersonSvc.selectByExample(example);
			if(list!=null){
				int size=list.size();
				for(int i=0;i<size;i++){
					//初始密码为12345678
					UpmsPerson person=list.get(i);
					String pwd=MD5Util.getEncryptedPwd("12345678", person.getSalt());
					person.setPassword(pwd);
					upmsPersonSvc.updateByPrimaryKeySelective(person);
					
				}
			}
			*/
			
			//ILoginService loginSvc=(LoginService)SpringContextUtil.getBean(LoginService.class);
			//System.out.println(RockJsonUtil.toJson(loginSvc.primaryLoginByPassword("500243198604195650", "12345678")));
			
			
		} catch (Exception e) {
			log.error("==>DubboProvider context start error:", e);
		}
		synchronized (UpmsDubboProviderMain.class) {
			while (true) {
				try {
					UpmsDubboProviderMain.class.wait();
				} catch (InterruptedException e) {
					log.error("== synchronized error:", e);
				}
			}
		}
	}
}
